export default function (config){
    return new Promise(function (resolve, reject){
        const {url , params={} ,jsonp='callback'} = config;
        const fnName = 'shen' + Math.random().toString(36).slice(2) + Date.now();
        window[fnName] = resolve;
        const script = document.createElement('script');
        script.src = url;
        params[jsonp] = fnName;
        script.src += '?' + Object.keys(params).map(key=>key + '=' + params[key]).join('&');
        script.onload = function (){
            document.body.removeChild(script);
            delete window[fnName];
        }

        document.body.appendChild(script);
    })

}